package pong.business.events;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class KeyboardController implements KeyListener {

	private PlayerInputListener listener;
	
	public KeyboardController(PlayerInputListener listener) {
		this.listener = listener;
	}
	
	public void keyPressed(KeyEvent event) {
		
		if(event.getKeyCode()==KeyEvent.VK_UP){
			listener.player1Up();
		}
		
		else if(event.getKeyCode()==KeyEvent.VK_DOWN){
			listener.player1Up();
		}
		
		else if(event.getKeyCode()==KeyEvent.VK_E){
			listener.player1Up();
		}
		
		else if(event.getKeyCode()==KeyEvent.VK_D){
			listener.player1Up();
		}
		
		else if(event.getKeyCode()==KeyEvent.VK_P){
			listener.pause();
		}
	}

	public void keyReleased(KeyEvent event) {
		// Does nothing.
	}

	public void keyTyped(KeyEvent event) {
		// Does nothing.
	}

}
